// component/oneword/oneword.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        text: '',
        from: "",
        Url:"106.55.106.183:7777/不该_%28with_aMEI%29-周杰伦-7134989.mp3",
        imageUrl: "https://cdn.pixabay.com/photo/2015/03/28/16/40/lake-696098_960_720.jpg",
        image: [
            "https://www4.bing.com//th?id=OHR.ValvestinoDam_ZH-CN8397604653_1920x1080.jpg&rf=LaDigue_1920x1080.jpg",
            "https://cdn.pixabay.com/photo/2013/07/18/20/26/sea-164989_960_720.jpg",
            "https://cdn.pixabay.com/photo/2015/03/28/16/40/lake-696098_960_720.jpg",
            "https://cdn.pixabay.com/photo/2013/04/04/12/34/mountains-100367_960_720.jpg",
            "https://cdn.pixabay.com/photo/2014/10/26/17/19/fisherman-504098_960_720.jpg",
            "https://cdn.pixabay.com/photo/2014/10/07/13/48/mountain-477832_960_720.jpg",
            "https://cdn.pixabay.com/photo/2015/12/01/20/28/road-1072821_960_720.jpg",
            "https://cdn.pixabay.com/photo/2014/09/10/00/59/mountains-440520_960_720.jpg",
            "https://cdn.pixabay.com/photo/2015/03/28/16/40/lake-696098_960_720.jpg"
        ]
    },

    /**
     * 组件的方法列表
     */
    methods: {
        getOneWord() {
            var that=this
            wx.request({
                url: 'https://international.v1.hitokoto.cn',
                method: 'GET',
                success(res) {
                    console.log(res)
                    that.setData({
                        text: res.data.hitokoto,
                        from: res.data.from
                    })
                }
            })
        },
        getBackgroundImage() {
            var that=this
            wx.request({
                url: 'https://international.v1.hitokoto.cn/',
                method: 'GET',
                success(res) {
                    console.log(res)
                    that.setData({
                        text: res.data.hitokoto,
                        from: res.data.from
                    })
                }
            })
        },
        changeImage(){
            console.log(Math.floor(Math.random()*10))
            var index=Math.floor(Math.random()*10)+1
            this.setData({
                imageUrl:this.data.image[index]
            })
        },
    }
})